package com.isoft.hospital.dao;

import com.isoft.hospital.entity.Patient;
import com.isoft.hospital.entity.Prescription;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface PatientDao {
    @Select("select * from patient")
    List<Patient> selectAll();

//   @Insert("insert into patient(p_id,p_name,p_sex,bl_id,p_adress,p_sf) values(#{p_id},#{p_name},#{p_sex},#{bl_id},#{p_adress},#{p_sf})")
@Insert("insert into patient(p_id,p_name,p_sex,p_adress,p_sf) values(#{p_id},#{p_name},#{p_sex},#{p_adress},#{p_sf})")
    int insert(Patient patient); //与Impl关联
//    @Insert("insert into patient(p_name,p_sf) values(#{p_name},#{p_sf})")
//    int insertguahao(Patient patient); //与Impl关联
    @Delete("delete from patient where p_id=#{p_id}")
    int delete(int p_id);

    @Update("update  patient set p_name=#{p_name},p_sex=#{p_sex},bl_id=#{bl_id},p_adress=#{p_adress},p_sf=#{p_sf} where p_id=#{p_id}")
    int update(Patient patient);
    @Select("select * from patient where p_id=#{p_id} ")
    Patient findById(int p_id);
    @Select("select * from patient where p_sf=#{p_sf}")
    Patient findBypsf(String p_sf);
}